package com.linkai.多线程._06_syn;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @Description: 测试 JUC 安全类型的集合
 * @Author: 林凯
 * @Date: 2021/10/19 22:49
 */
public class TestJUC {
    public static void main(String[] args) {
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList();
        for (int i = 0; i < 10000; i++) {
            new Thread(()->{
                list.add(Thread.currentThread().getName());
            }).start();
        }
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(list.size());

    }
}
